package cn.linjianhui.flink.sample.web.model;

import lombok.Getter;
import lombok.Setter;

import java.text.DecimalFormat;

@Getter
@Setter
public class BrandSalesResult {
    private double salesAmount;
    private String brandCode;
    private String brandName;

    public double getSalesAmount() {
        return round(salesAmount, 4);
    }

    private double round(double value, int scale){
        StringBuilder pattern = new StringBuilder("#.");
        for(int i = 0; i < scale; i++) pattern.append("0");
        DecimalFormat df = new DecimalFormat(pattern.toString());
        return Double.valueOf(df.format(value));
    }
}
